
source(here::here("code/load.R"))

files <- paste0(here("data/meta_analyses_raw/EshEtAl2021/"),
                list.files(here("data/meta_analyses_raw/EshEtAl2021/"), pattern = ".xlsx"))

read_dir <- function(file_name){
  read_excel(file_name) |>
  mutate(meta_id = "EshEtAl2021",
         question = "Effect of EU brand on citizen's trust in policies",
         subfield = "PA",
         dv = Policy,
         estimate = as.numeric(gsub(" \\(.*", "", `SMD (95% CI)`)),
         conf.low = as.numeric(gsub(".*\\((.*),.*", "\\1", `SMD (95% CI)`)),
         conf.high = as.numeric(gsub(".*,(.*)\\).*", "\\1", `SMD (95% CI)`)),
         std.error = (conf.high - conf.low) / 3.92,
         study_id = NA,
         overall_effect = "both") |>
    select(meta_id,
           study_id,
           question,
           subfield,
           dv,
           estimate,
           std.error,
           overall_effect)
}

files |>
  map_df(~ read_dir(.)) |>
  write_csv(here("data/meta_analyses_clean/EshEtAl2021.csv"))

  
  
